package scenic;

/**
 * Contains constants for different pixel formats. All
 * formats are specified from most significant bit (MSB) to 
 * least significant bit (LSB). In memory the bytes
 * area stored from LSB to MSB. So the format A8R8G8B8 is
 * stored in memory in the following order: blue, green, red and 
 * alpha.
 */
public class Format {
	/**
	 * Alpha, red, green and blue channels using 8-bits 
	 * per channel.
	 */
	public static final int A8R8G8B8 = 0;
	/**
	 * Red, green and blue channels using 8-bits 
	 * per channel. The alpha channel is set to 1.
	 */
	public static final int R8G8B8 = 1;
	/**
	 * Luminance using 8-bits. The red, green and blue channels
	 * are set to the luminance value. The alpha channel is set to 1.
	 */
	public static final int L8 = 2;
	/**
	 * Alpha using 8-bits. The red, green and blue channels
	 * are set to 0.
	 */
	public static final int A8 = 3;
	/**
	 * A single alpha-luminance value using 8-bits. 
	 * The red, green, blue and alpha channels are set 
	 * to the alpha-luminance value.
	 */
	public static final int AL8 = 4;
	
	/**
	 * Contains information about a pixel format.
	 */
	public static class Info {
		private int size;
		
		private Info(int size) {
			this.size = size;
		}		
		
		/**
		 * Returns the size of a pixel in bytes.
		 */
		public int getSize() {
			return size;
		}
	}
	
	private static final Info[] formats = {
		new Info(4),
		new Info(3),
		new Info(1),
		new Info(1),
		new Info(1)
	};
	
	private Format() {
	}
	
	/**
	 * Gets the information for the given format.
	 */
	public static Info getInfo(int format) {
		return formats[format];
	}
}
